package fr.esipe.agenda.parser;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Event {

    public static final DateFormat DATE_TIME_FORMAT = new SimpleDateFormat("dd/MM/yyyy HH:mm");

    private static final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm");

    private String formationId;

    private Date startTime;

    private Date endTime;

    private List<String> labels = new ArrayList<String>(4);

    public void setFormationId(String formationId) {
        this.formationId = formationId;
    }

    public String getFormationId() {
        return formationId;
    }

    public void setLabels(List<String> labels) {
        this.labels = labels;
    }

    public void addLabel(String label) {
        labels.add(label);
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public List<String> getLabels() {
        return labels;
    }

    @Override
    public String toString() {

        StringBuilder builder = new StringBuilder();
        builder.append("Event[");
        if (labels.size() > 0)
            builder.append(labels.get(0)).append("|");
        builder.append(DATE_TIME_FORMAT.format(startTime));
        builder.append("-");
        builder.append(TIME_FORMAT.format(endTime));
        builder.append("|");
        builder.append(formationId);
        builder.append("]");

        return builder.toString();
    }
}
